using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;

namespace NETL.Engine.Data
{
	public class TextMessage : MessageBase
	{
		private string myData;
		
		public TextMessage(string name, string data)
		{
			Name = name;
			myData = data;
		}

		public TextMessage(string name, DateTime created, string data, Guid id)
		{
			Name = name;
			Created = created;
			Id = id;
			myData = data;
		}

		public string Data
		{
			get { return myData; }
			set { myData = value; }
		}

		public List<string> Rows
		{
			get
			{
				return new List<string>(myData.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
			}
		}

		public override string ToString()
		{
			StringBuilder sb = new StringBuilder("<TextMessage>");
			sb.AppendFormat("<Id>{0}</Id>", Id);
			sb.AppendFormat("<Name>{0}</Name>", Name);
			sb.AppendFormat("<Created>{0}</Created>", Created);
			sb.AppendFormat("<Data>{0}</Data>", Data);
			sb.Append("</TextMessage>");

			return sb.ToString();
		}
	}
}
